
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>redis17 Redis.config详解 · Redis</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="<yangxin19970404@163.com>">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="redis18 Redis持久化RDB.html" />
    
    
    <link rel="prev" href="redis16 RedisUtil.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="redis01 redis开始.html">
            
                <a href="redis01 redis开始.html">
            
                    
                    redis01 redis开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="redis02 redis安装.html">
            
                <a href="redis02 redis安装.html">
            
                    
                    redis02 redis安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="redis03 redis基础知识.html">
            
                <a href="redis03 redis基础知识.html">
            
                    
                    redis03 redis基础知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="redis04 String数据类型详解.html">
            
                <a href="redis04 String数据类型详解.html">
            
                    
                    redis04 String数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="redis05 List数据类型详解.html">
            
                <a href="redis05 List数据类型详解.html">
            
                    
                    redis05 List数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="redis06 Set数据类型详解.html">
            
                <a href="redis06 Set数据类型详解.html">
            
                    
                    redis06 Set数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="redis07 Hash数据类型详解.html">
            
                <a href="redis07 Hash数据类型详解.html">
            
                    
                    redis07 Hash数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="redis08 Zset数据类型详解.html">
            
                <a href="redis08 Zset数据类型详解.html">
            
                    
                    redis08 Zset数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="redis09 Geospatial地理位置详解.html">
            
                <a href="redis09 Geospatial地理位置详解.html">
            
                    
                    redis09 Geospatial地理位置详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="redis10 Hyperloglog基数统计详解.html">
            
                <a href="redis10 Hyperloglog基数统计详解.html">
            
                    
                    redis10 Hyperloglog基数统计详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="redis11 Bitmap位图场景详解.html">
            
                <a href="redis11 Bitmap位图场景详解.html">
            
                    
                    redis11 Bitmap位图场景详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="redis12 Redis事务操作.html">
            
                <a href="redis12 Redis事务操作.html">
            
                    
                    redis12 Redis事务操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="redis13 Redis实现乐观锁.html">
            
                <a href="redis13 Redis实现乐观锁.html">
            
                    
                    redis13 Redis实现乐观锁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="redis14 Jedis.html">
            
                <a href="redis14 Jedis.html">
            
                    
                    redis14 Jedis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="redis15 springBoot整合redis.html">
            
                <a href="redis15 springBoot整合redis.html">
            
                    
                    redis15 springBoot整合redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="redis16 RedisUtil.html">
            
                <a href="redis16 RedisUtil.html">
            
                    
                    redis16 RedisUtil
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.18" data-path="redis17 Redis.config详解.html">
            
                <a href="redis17 Redis.config详解.html">
            
                    
                    redis17 Redis.config详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="redis18 Redis持久化RDB.html">
            
                <a href="redis18 Redis持久化RDB.html">
            
                    
                    redis18 Redis持久化RDB
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="redis19 Redis持久化AOF.html">
            
                <a href="redis19 Redis持久化AOF.html">
            
                    
                    redis19 Redis持久化AOF
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="redis20 Redis发布订阅.html">
            
                <a href="redis20 Redis发布订阅.html">
            
                    
                    redis20 Redis发布订阅
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="redis21 Redis主动复制.html">
            
                <a href="redis21 Redis主动复制.html">
            
                    
                    redis21 Redis主动复制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="redis21 Redis哨兵模式.html">
            
                <a href="redis21 Redis哨兵模式.html">
            
                    
                    redis21 Redis哨兵模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="redis22 Redis缓存穿透和雪崩.html">
            
                <a href="redis22 Redis缓存穿透和雪崩.html">
            
                    
                    redis22 Redis缓存穿透和雪崩
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >redis17 Redis.config详解</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="redisconfig&#x8BE6;&#x89E3;">Redis.config&#x8BE6;&#x89E3;</h3>
<p>&#x542F;&#x52A8;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x662F;&#x901A;&#x8FC7;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x542F;&#x52A8;&#x7684;</p>
<blockquote>
<p>&#x5355;&#x4F4D;</p>
</blockquote>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210319154812.png" alt=""></p>
<ol>
<li>&#x914D;&#x7F6E;&#x6587;&#x4EF6; unit &#x5355;&#x4F4D;&#x5BF9;&#x5927;&#x5C0F;&#x5199;&#x4E0D;&#x654F;&#x611F;</li>
</ol>
<blockquote>
<p>&#x5305;&#x542B;</p>
</blockquote>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210319154941.png" alt="">
&#x5C31;&#x662F;&#x597D;&#x6BD4;&#x6211;&#x4EEC;&#x5B66;&#x4E60;Spring,import,include</p>
<blockquote>
<p>&#x7F51;&#x7EDC;</p>
</blockquote>
<pre><code class="lang-shell">    bind  127.0.0.1  # &#x7ED1;&#x5B9A;&#x7684;IP
    protected-mode  yes  # &#x4FDD;&#x62A4;&#x6A21;&#x5F0F;
    port 6379 # &#x7AEF;&#x53E3;
    daemonize yes # &#x4EE5;&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;&#x7684;&#x65B9;&#x5F0F;&#x8FD0;&#x884C; , &#x9ED8;&#x8BA4;&#x662F;no , &#x6211;&#x4EEC;&#x9700;&#x8981;&#x81EA;&#x5DF1;&#x6253;&#x5F00;yes
    pidfile /var/run/redis_6379.pid  # &#x5982;&#x679C;&#x540E;&#x53F0;&#x8FD0;&#x884C;,&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;pid&#x6587;&#x4EF6;
    loglevel notice  # &#x65E5;&#x5FD7;&#x7EA7;&#x522B; , notice&#x662F;&#x751F;&#x4EA7;&#x73AF;&#x5883;
    logfile &quot;&quot;  # &#x65E5;&#x5FD7;&#x6587;&#x4EF6;&#x4F4D;&#x7F6E;&#x540D;
    databases 16  # &#x9ED8;&#x8BA4;&#x6570;&#x636E;&#x5E93;&#x6570;&#x91CF; 16
    always-show-logo  yes # &#x662F;&#x5426;&#x663E;&#x793A;logo
</code></pre>
<blockquote>
<p><strong>&#x5FEB;&#x7167;</strong></p>
</blockquote>
<p>&#x6301;&#x4E45;&#x5316;,&#x5728;&#x89C4;&#x5B9A;&#x65F6;&#x95F4;&#x5185;,&#x6267;&#x884C;&#x4E86;&#x591A;&#x5C11;&#x6B21;&#x64CD;&#x4F5C;,&#x5219;&#x4F1A;&#x6301;&#x4E45;&#x5316;&#x5230;&#x6587;&#x4EF6;.rdb.aof
redis&#x662F;&#x5185;&#x5B58;&#x6570;&#x636E;&#x5E93;,&#x5982;&#x679C;&#x6CA1;&#x6709;&#x6301;&#x4E45;&#x5316;,&#x90A3;&#x4E48;&#x6570;&#x636E;&#x65AD;&#x70B9;&#x5373;&#x5931;~</p>
<pre><code class="lang-shell">  save 900 10  # &#x5982;&#x679C;&#x5728;900s&#x5185;,&#x81F3;&#x5C11;&#x6709;10&#x4E2A;key&#x8FDB;&#x884C;&#x4E86;&#x4FEE;&#x6539;,&#x6211;&#x4EEC;&#x5C31;&#x4F1A;&#x8FDB;&#x884C;&#x6301;&#x4E45;&#x5316;&#x64CD;&#x4F5C;
  stop-writes-on-bgsave-error  yes  # &#x6301;&#x4E45;&#x5316;&#x5982;&#x679C;&#x51FA;&#x9519;,&#x662F;&#x5426;&#x8FD8;&#x9700;&#x8981;&#x7EE7;&#x7EED;&#x5DE5;&#x4F5C;
  rdbcompression yes # &#x662F;&#x5426;&#x538B;&#x7F29;rdb&#x6587;&#x4EF6;,&#x9700;&#x8981;&#x8FDB;&#x884C;&#x6D88;&#x8017;&#x4E00;&#x4E9B;CPU&#x8D44;&#x6E90;
  rdbchecksun  yes  #  &#x4FDD;&#x5B58;rdb&#x6587;&#x4EF6;&#x7684;&#x65F6;&#x5019;,&#x8FDB;&#x884C;&#x9519;&#x8BEF;&#x7684;&#x68C0;&#x67E5;&#x6821;&#x9A8C;
  dir  ./  # rdb&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x76EE;&#x5F55;
</code></pre>
<blockquote>
<p>replication&#x590D;&#x5236;,&#x6211;&#x4EEC;&#x540E;&#x9762;&#x8BB2;&#x4E3B;&#x4ECE;&#x590D;&#x5236;&#x518D;&#x8BB2;&#x89E3;</p>
</blockquote>
<pre><code class="lang-shell">replicaof ip port  # &#x5728;&#x4ECE;&#x673A;&#x4E2D;&#x914D;&#x7F6E;&#x4E3B;&#x673A;&#x7684;ip&#x548C;&#x7AEF;&#x53E3;
masterauth  &#x5BC6;&#x7801;  # &#x4E3B;&#x673A;&#x7684;&#x5BC6;&#x7801;
</code></pre>
<blockquote>
<p>security &#x5B89;&#x5168;</p>
</blockquote>
<p>&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x5BC6;&#x7801;,&#x9ED8;&#x8BA4;&#x662F;&#x6CA1;&#x6709;&#x5BC6;&#x7801;&#x7684;</p>
<pre><code class="lang-shell">config set requirepass &quot;123456&quot;   # &#x8BBE;&#x7F6E;&#x5BC6;&#x7801;
auth 123456  # &#x767B;&#x5F55;&#x5BC6;&#x7801;
</code></pre>
<blockquote>
<p>client</p>
</blockquote>
<pre><code class="lang-shell">maxclients 10000  # &#x8BBE;&#x7F6E;&#x80FD;&#x8FDE;&#x63A5;&#x4E0A;redis&#x7684;&#x6700;&#x5927;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x6570;&#x91CF;
maxmemory &lt;bytes&gt; # redis&#x914D;&#x7F6E;&#x6700;&#x5927;&#x7684;&#x5185;&#x5B58;&#x5BB9;&#x91CF;&apos;
maxmemory-policy noeviction  # &#x5185;&#x5B58;&#x8FBE;&#x5230;&#x4E0A;&#x9650;&#x4E4B;&#x540E;&#x7684;&#x5904;&#x7406;&#x7B56;&#x7565;
</code></pre>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210319162229.png" alt=""></p>
<blockquote>
<p>aof&#x914D;&#x7F6E;</p>
</blockquote>
<pre><code class="lang-shell">appendonly no  # &#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x5F00;&#x542F;aof&#x6A21;&#x5F0F;&#x7684;,&#x9ED8;&#x8BA4;&#x662F;&#x4F7F;&#x7528;rdb&#x65B9;&#x5F0F;&#x6301;&#x4E45;&#x5316;&#x7684;,&#x5728;&#x5927;&#x90E8;&#x5206;&#x6240;&#x6709;&#x7684;&#x60C5;&#x51B5;&#x4E0B;.rdb&#x5B8C;&#x5168;&#x591F;&#x7528;
appendfilename  &quot;appendonly.aof&quot; # &#x6301;&#x4E45;&#x5316;&#x6587;&#x4EF6;&#x7684;&#x540D;&#x5B57; ,

appendsync  always  # &#x6BCF;&#x6B21;&#x4FEE;&#x6539;&#x90FD;&#x4F1A;&#x8FDB;&#x884C;&#x540C;&#x6B65;
appendsync  everysec # &#x6BCF;&#x79D2;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x540C;&#x6B65;.&#x53EF;&#x80FD;&#x4F1A;&#x4E22;&#x5931;&#x6570;&#x636E;
appendsync  no   # &#x4E0D;&#x6267;&#x884C;&#x540C;&#x6B65;,&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4F1A;&#x81EA;&#x5DF1;&#x540C;&#x6B65;&#x6570;&#x636E;,&#x901F;&#x5EA6;&#x6700;&#x5FEB;
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="redis16 RedisUtil.html" class="navigation navigation-prev " aria-label="Previous page: redis16 RedisUtil">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="redis18 Redis持久化RDB.html" class="navigation navigation-next " aria-label="Next page: redis18 Redis持久化RDB">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"redis17 Redis.config详解","level":"1.18","depth":1,"next":{"title":"redis18 Redis持久化RDB","level":"1.19","depth":1,"path":"redis18 Redis持久化RDB.md","ref":"redis18 Redis持久化RDB.md","articles":[]},"previous":{"title":"redis16 RedisUtil","level":"1.17","depth":1,"path":"redis16 RedisUtil.md","ref":"redis16 RedisUtil.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"<yangxin19970404@163.com>","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Redis","language":"zh-hans","gitbook":"3.2.3","description":"Redis > 缓存技术"},"file":{"path":"redis17 Redis.config详解.md","mtime":"2021-04-17T07:00:09.658Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:48:08.480Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

